<?php
namespace app\index\controller;

use think\Controller;

class Wx extends Common
{

	public function _initialize()
    {   
        parent::_initialize();
        $this->appId = 'wx94e12074e84e138d';
        $this->appSecret = 'b188d11fc1fbce2a2a8c56d6ca978092';
    }

     /**
    * 生成微信登录二维码操作
    * @param  appId 微信公众号id 
    * @param  url 扫描成功跳转
    * @author 张杰
    * @time
    */
    public function wxlogin(){
        if(empty($opid)){
            $appId = $this->appId;
            $url = urlEncode('https://jinanvr.cn/Wxlogin/back'); //授权成功返回地址
            //$uri = urlEncode('http://travelapi.hichinatrip.com/index/Wxlogin/back');
            //下面$url请求授权登录地址,此处为静默授权，scope可改成snsapi_userinfo，注意此URL不能换行,静默授权只能获取_token 和 openId
            $url = 'https://open.weixin.qq.com/connect/qrconnect?appid='.$appId.'&redirect_uri='.$url.'&response_type=code&scope=snsapi_login&state=STATE#wechat_redirect';
            header("Location:".$url);
            exit(0);
        }
    }

    public function nohtml(){
        return $this->fetch();
    }

}
